/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package utilitaires.cryptographie;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author Fred
 */
public class Sha512 {

    public static boolean comparer(String hash, String mdp) {
        Boolean resultat = false;
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-512");
            StringBuilder sb = new StringBuilder();
            for (byte b : md.digest(mdp.getBytes())) {
                sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
            }
            resultat = hash.equals(sb.toString());
        } catch (NoSuchAlgorithmException ex) {
        }
        return resultat;
    }
}
